package com.ruoyi.boat.controller;

import java.util.List;

import com.ruoyi.boat.aop.AvoidDuplicate;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.boat.domain.RadarData;
import com.ruoyi.boat.service.IRadarDataService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 测风雷达数据Controller
 *
 * @author ruoyi
 * @date 2023-08-09
 */
@Controller
@RequestMapping("/boat/radarData")
public class RadarDataController extends BaseController {
    private String prefix = "boat/radarData";

    @Autowired
    private IRadarDataService radarDataService;

    @RequiresPermissions("boat:radarData:view")
    @GetMapping()
    public String radarData() {
        return prefix + "/radarData";
    }

    /**
     * 查询测风雷达数据列表
     */
    @RequiresPermissions("boat:radarData:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RadarData radarData) {
        startPage();
        List<RadarData> list = radarDataService.selectRadarDataList(radarData);
        return getDataTable(list);
    }

    /**
     * 导出测风雷达数据列表
     */
    @RequiresPermissions("boat:radarData:export")
    @Log(title = "测风雷达数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AvoidDuplicate
    @ResponseBody
    public AjaxResult export(RadarData radarData) {
        List<RadarData> list = radarDataService.selectRadarDataList(radarData);
        ExcelUtil<RadarData> util = new ExcelUtil<RadarData>(RadarData.class);
        return util.exportExcel(list, "测风雷达数据");
    }

    /**
     * 新增测风雷达数据
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存测风雷达数据
     */
    @RequiresPermissions("boat:radarData:add")
    @Log(title = "测风雷达数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RadarData radarData) {
        return toAjax(radarDataService.insertRadarData(radarData));
    }

    /**
     * 修改测风雷达数据
     */
    @RequiresPermissions("boat:radarData:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        RadarData radarData = radarDataService.selectRadarDataById(id);
        mmap.put("radarData", radarData);
        return prefix + "/edit";
    }

    /**
     * 修改保存测风雷达数据
     */
    @RequiresPermissions("boat:radarData:edit")
    @Log(title = "测风雷达数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RadarData radarData) {
        return toAjax(radarDataService.updateRadarData(radarData));
    }

    /**
     * 删除测风雷达数据
     */
    @RequiresPermissions("boat:radarData:remove")
    @Log(title = "测风雷达数据", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(radarDataService.deleteRadarDataByIds(ids));
    }
}
